package com.hmily.dubbo.consumer.sync;

import com.hmily.dubbo.api.UserQueryFacade;
import org.apache.dubbo.container.Main;
import org.apache.dubbo.container.spring.SpringContainer;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * <h1>利用 XML 代码来启动消费方。</h1>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2021-10-18
 */
public class XmlConsumerApplication {

    public static void main(String[] args) throws IOException {
        String configPath = "classpath*:META-INF/spring/consumer.xml";
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(configPath);
        ctx.refresh();

        // 接口调用
        UserQueryFacade userQueryFacade = ctx.getBean(UserQueryFacade.class);
        System.out.println(userQueryFacade.queryUser("hmily"));


        // 阻塞等待
        System.in.read();
    }

    public static void main1(String[] args) throws IOException {
        Main.main(new String[]{"spring"});

        // 接口调用
        UserQueryFacade userQueryFacade = SpringContainer.getContext().getBean(UserQueryFacade.class);
        System.out.println(userQueryFacade.queryUser("hmily"));
    }
}
